#ifndef __heibai_chessboard_opencv__h__
#define __heibai_chessboard_opencv__h__


#include "heibai_chessboard.h"
#include <opencv/cv.h>
#define HEIBAI_BRIM_WIDE_LENGTH	20			//边宽
#define HEIBAI_PROFILE_LENGTH	121			//数据栏
#define HEIBAI_NODE_LENGTH	41			//格子大小
#define HEIBAI_CHELL_SIZE	36			//棋子大小
#define HEIBAI_BOARD_LENGTH	(8*HEIBAI_NODE_LENGTH)	//棋面大小
#define HEIBAI_SUM_WIDTH	(HEIBAI_BOARD_LENGTH+HEIBAI_PROFILE_LENGTH+3*HEIBAI_BRIM_WIDE_LENGTH)	//整个宽
#define HEIBAI_SUM_HEIGTH	(HEIBAI_BOARD_LENGTH+2*HEIBAI_BRIM_WIDE_LENGTH)				//高
#define HEIBAI_PROFILE_CHESS_CENTER_X (HEIBAI_BRIM_WIDE_LENGTH * 2 + HEIBAI_BOARD_LENGTH + HEIBAI_PROFILE_LENGTH / 2 + 1)
#define HEIBAI_PROFILE_CHESS_CENTER_Y1	(HEIBAI_BRIM_WIDE_LENGTH + HEIBAI_CHELL_SIZE)
#define HEIBAI_PROFILE_CHESS_CENTER_Y2	(HEIBAI_SUM_HEIGTH - HEIBAI_PROFILE_CHESS_CENTER_Y1)
#define HEIBAI_PROFILE_CHESS_CENTER_Y	((HEIBAI_PROFILE_CHESS_CENTER_Y1 + HEIBAI_PROFILE_CHESS_CENTER_Y2) / 2)
#define HEIBAI_PROFILE_TEXT_X	(HEIBAI_PROFILE_CHESS_CENTER_X - HEIBAI_PROFILE_LENGTH / 4)
#define HEIBAI_PROFILE_TEXT_Y1	(HEIBAI_PROFILE_CHESS_CENTER_Y1 + HEIBAI_CHELL_SIZE + HEIBAI_CHELL_SIZE / 3)
#define HEIBAI_PROFILE_TEXT_Y2	(HEIBAI_PROFILE_CHESS_CENTER_Y2 - HEIBAI_CHELL_SIZE)

#define USER_BLACK_COLOR HEIBAI_BLACK
#define USER_WHITE_COLOR HEIBAI_WHITE

#define HEIBAI_SIGNAL_MOUSE	1
#define HEIBAI_SIGNAL_KEYBOARD	2
#define HEIBAI_SIGNAL_ROLL	3

class CHBSignal
{
	public:
		int m_signal;
		int m_key;
		int m_mouse_x;
		int m_mouse_y;
		int m_k;
};

class CHBChessBoardOpencv : public CHBChessBoard
{
	public:
		CHBChessBoardOpencv(char * name);
		~CHBChessBoardOpencv();
		void ShowBoard();
		void PutChess(int x, int y, int user);
		void GetSignal(int &x, int &y);
		void SetProfile(int type, int user1Chess, int user2Chess, int user = 0);
	private:
		void SetSignal(int sig, int x, int y, int key);
		void DrawBoardLine();
		void DrawBack();
		void DrawProfileBack();
		void DrawLine();
		void DrawProfileChess();
		static void mouseSig(int event, int x, int y, int flags, void* param);
	private:
		IplImage* m_img;
		char * m_sWinName;
		CHBSignal m_signal;
		int m_k;
};

#endif
